<%--
  Created by IntelliJ IDEA.
  User: 84965
  Date: 2019/9/11
  Time: 15:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<meta charset="utf-8">
<head>
    <title>Title</title>
    <script type="text/javascript" src="js/echarts.js"></script>
    <script type="text/javascript" src="js/jquery-3.1.1.js"></script>
    <script type="text/javascript">
        $(function(){
            $.get("nanny.do?m=selectNannyWorks",function (respText) {
               var works = JSON.parse(respText);
               var names = new Array();
               var counts = new Array();
               //把json数组中的名字和数量存入不同的数据
                for (var i = 0;i<works.length;i++){
                    names[i] = works[i].nannyName;
                    console.log(names[i]);
                    counts[i] = works[i].workCount;
                }
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('nannyWork'));

                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: '保姆统计图'
                    },
                    tooltip: {},
                    legend: {
                        data:['保姆']
                    },
                    xAxis: {
                        data:names
                    },
                    yAxis: {},
                    series: [{
                        name: '工作量',
                        type: 'bar',
                        data: counts
                    }]
                };

                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            });


        });


    </script>

</head>
<body>
<div id="nannyWork" style="width: 500px;height: 300px;background-color: #cccccc"></div>
</body>
</html>
